<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS 盒子模型</title>
    <style>
        :root{
            /* 定义变量 */
            --d-W:1200px;
            --d-H:150px;
            --d-padding:10px;
            --d-margin:10px;
            --d-border:1px;
            --d-Num: 4;
        }
       *{
        margin: 0;
        padding: 0;
       }
       .container{
        width:var(--d-W);
        height: var(--d-H);
        background-color: red;
        margin: 100px auto;
       }
       .container div{
        width: calc(var(--d-W)/var(--d-Num) - var(--d-margin) * 2 - var(--d-padding) * 2 - var(--d-border) *2);
        height: calc(var(--d-H) - var(--d-margin) * 2 - var(--d-padding) * 2 - var(--d-border) *2);
        padding: var(--d-padding);
        margin: var(--d-margin);
        background-color: blue;
        float: left;
        color:white;
        border-width: var(--d-border);
        border-style: solid;
        border-color: green;
       }
    </style>
</head>
<body>
    <div class="container">
        <div>1</div>
        <div>1</div>
        <div>1</div>
        <div>1</div>
    </div>
</body>
</html>